package middol.notice

import groovy.transform.CompileStatic
import groovy.util.logging.Slf4j
import org.springframework.stereotype.Component

/**
* @Description:    上下文类，持有策略接口（通知上下文）
* @Author:         zhangjiayu@middol.com
* @CreateDate:     2020/10/21 10:27
* @Version:        1.0
*/
@Slf4j
@Component
@CompileStatic
class NoticeHandlerContext {
    private INoticeHandler noticeHandler

    void setNoticeHandler(INoticeHandler noticeHandler) {
        this.noticeHandler = noticeHandler
    }

    void handleSend(IMessage message){
        if(this.noticeHandler){
            this.noticeHandler.handleSend(message)
        }else{
            log.error("notice is null, please check notice service")
        }
    }
}
